import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-07-31
 * Time:10:02
 */
public class TestDemo {
    public static void main(String[] args) {
        int n = 5;
        int i = 1;
        int ret = 1;
        for(i = 1; i <= n; i++) {
            ret *= i;
        }
        System.out.println(ret);
    }
    public static void main8(String[] args) {
        int num = 2;
        switch(num%2) {
            case 0:
                System.out.println("num是偶数");
            case 1:
                System.out.println("num是奇数");
            default:
                System.out.println("程序异常");
                break;
        }
    }
    public static void main7(String[] args) {
        byte c = 1;
        int b = 20;
        int a = c;
        System.out.println(a);
        System.out.printf("%d\n", a >>> 1);
        System.out.println((b >>> 1));
    }
    public static void main6(String[] args) {
        int[] array = {9,8,7,2,5,4,1,0,6,3};
        System.out.println("排序前： " + Arrays.toString(array));
        bubbleSort(array);
        System.out.println("排序后： " + Arrays.toString(array));
    }
    public static void bubbleSort(int[] array) {
        int i = 0;
        int j = 0;
        for ( i = 0; i < array.length; i++) {
            int flag = 1;
            for (j = 1; j < array.length - i; j++) {
                if(array[j - 1] > array[j]) {
                    int tmp = array[j - 1];
                    array[j - 1] = array[j];
                    array[j] = tmp;
                    flag = 0;
                }
            }
            if(flag == 1) {
                return;
            }
        }
    }
    /**
     * 给定一个整型数组, 判定数组是否有序（递增）
     * @param args
     */
    public static void main5(String[] args) {
        int[] array1 = {1,2,3,4,5,7,6,8,9,10};
        int[] array2 = {1,2,3,4,5,6,7,8,9,10};
        System.out.println(isSort(array1));
        System.out.println(isSort(array2));
    }
    public static boolean isSort(int[] array) {

        for (int i = 1; i < array.length; i++) {
            if(array[i-1] > array[i]) {
                return false;
            }
        }
            return true;
    }
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int  key = scanner.nextByte();
        int[] array = {1,2,3,4,5,6,7,8,9};
        int index = binarySearch(array,key);
        System.out.println(index);
    }

    /**
     *
     * @param array 查找数组
     * @param key 查找的数
     * @return   若找到了就返回下标，没有找到就返回 -1；
     */
    public static int binarySearch(int[] array,int key) {
        int left = 0;
        int right = array.length - 1;
        int mid = (left + right) / 2;
        while (left <= right) {
            mid = (left + right) / 2;
            if (array[mid] < key) {
                left = mid + 1;
            } else if (array[mid] > key) {
                right = mid - 1;
            } else {
                return mid;
            }
        }
        return -1;
    }
    public static void main3(String[] args) {
        int[] array = {1,2,3,4,5,6};
        int[] ret = myCopyOf(array,2 * array.length);
        System.out.println(Arrays.toString(ret));
    }
    public static int[] myCopyOf(int[] array,int len) {
        int[] copy = new int[len];
        for (int i = 0; i < array.length; i++) {
            copy[i] = array[i];
        }
        return copy;
    }
    public static void main2(String[] args) {
         int[] array = {1,2,3,4,5,6};
         String ret = myToString(array);
        System.out.println(ret);
    }
    public static String myToString(int[] array) {
        String ret = "[";
        for (int i = 0; i < array.length; i++) {
            ret = ret + array[i] ;
            if (i < array.length - 1) {
                ret += ", ";
            }
        }
        ret = ret + "]";
        return ret;
    }
    public static void main1(String[] args) {
/*        int a = 10;
        int b = ++a;
        System.out.println(b);
        int c = a++;
        System.out.println(c);*/
/*        int a = 10;
        int b = 20;
        System.out.println(a == b);
        System.out.println(a != b);
        System.out.println(a < b);
        System.out.println(a > b);
        System.out.println(a <= b);
        System.out.println(a >= b);*/
        /*int a = 10;
        int b = 20;
        int c = 30;
        System.out.println(a < b && b < c);*/
//        int a = 10;
//        int b = 20;
//        int c = 30;
//        System.out.println(a < b || b < c);

/*        int a = 10;
        int b = 20;
        System.out.println(!(a < b));*/
        System.out.println(10 > 20 && 10 / 0 == 0); // 打印 false
        System.out.println(10 < 20 || 10 / 0 == 0); // 打印 true
    }
}
